//
//  BaseViewController.swift
//  WaiBao
//
//  Created by 赵佟越 on 17/5/11.
//  Copyright © 2017年 zhaotongyue. All rights reserved.
//

import UIKit
//import RxSwift

extension UIViewController {
    class func currentViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
        if let nav = base as? UINavigationController {
            return currentViewController(base: nav.visibleViewController)
        }
        if let tab = base as? UITabBarController {
            return currentViewController(base: tab.selectedViewController)
        }
        if let presented = base?.presentedViewController {
            return currentViewController(base: presented)
        }
        return base
    }
}


class BaseViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        makeBaseUIBaseVC()
        layoutNavigationBaseVC()
        // Do any additional setup after loading the view.
    }
    
    //MARK: - Private Methods
    func makeBaseUIBaseVC(){
        let backImageView = UIImageView.init()
        backImageView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight)
        backImageView.image = UIImage.init(named: "底色 拷贝 2@2x")
        self.view.addSubview(backImageView)
        
        self.view.backgroundColor = UIColor.white
    }
    
    func layoutNavigationBaseVC(){
        UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor : UIColor.clear], for: .normal)
        self.navigationController?.navigationBar.isTranslucent = true;
        
            let bgColor = UIColor.clear
         self.navigationController?.navigationBar.barTintColor = bgColor
        
        let dict:NSDictionary = [NSAttributedStringKey.foregroundColor: UIColor.white,NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 18)]
        //标题颜色
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(named: "backTopView"), for: .default)
        self.navigationController?.navigationBar.titleTextAttributes = dict as? [NSAttributedStringKey : AnyObject]
       UINavigationBar.appearance().tintColor = UIColor.white
        
        self.navigationController?.navigationBar.tintColor = UIColor.white
        

//        let item = UIBarButtonItem(title: "", style: .plain, target: self, action: nil)
//        self.navigationItem.backBarButtonItem = item
    }
    func LogIn(){
        let nav = UINavigationController(rootViewController: LogInViewController())
        self.present(nav, animated: true) {
            
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
